package enumdemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Test {
    public static void main(String[] args) {
        Class<?> c=null;
        try {
            c=Class.forName("enumdemo.TestEnum");
           Constructor<?> constructor= c.getDeclaredConstructor(String.class,int.class,String.class,int.class);
           //后面两个参数是隐式的默认给父类的
           constructor.setAccessible(true);
           //枚举是不能反射的
           TestEnum testEnum=(TestEnum) constructor.newInstance("棕色",6);
            System.out.println(testEnum);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
